import React from 'react';
import { ModalForm, ProFormTextArea } from '@ant-design/pro-form';

export type FormValueType = {
    target?: string;
    template?: string;
    type?: string;
    time?: string;
    frequency?: string;
  } & Partial<string>;

  
export type ChooseProps = {
    onCancel: (flag?: boolean, formVals?: FormValueType) => void;
    onSubmit: (values: string[]) => Promise<void>;
    modalVisible: boolean;
    inputFlag:boolean;
    title:string;
    label:string;
    placeholder:string;
  };

  
const InputDialog: React.FC<ChooseProps> = (props)=>{


    return (
        <ModalForm
        title={props.title}
        visible={props.modalVisible}
        onFinish={async (val)=>{
          props.onSubmit([val.remark]);
          return true;
        }}
        modalProps={{
          onCancel: () => props.onCancel(),
        }}
      >
        <ProFormTextArea name="remark" placeholder={props.placeholder} label={props.label} rules={[
                  {
                    required: props.inputFlag,
                    message:props.placeholder
                  },
                ]}  fieldProps={{showCount:true,maxLength:200}}/>
      </ModalForm>
    );
}
export default InputDialog;